//
//  HZMarketCollectionViewCell.m
//  HZTC_Stock
//
//  Created by MayerF on 17/3/10.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZMarketCollectionViewCell.h"

#define kMargin 10

@interface HZMarketCollectionViewCell()

@end

@implementation HZMarketCollectionViewCell

#pragma mark -
#pragma mark 生命周期
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self p_commonInit];
    }
    return self;
}

- (void)p_commonInit
{
    self.pName = [UILabel new];
    self.pPrice = [UILabel new];
    self.pZhangDie = [UILabel new];
    self.pFuDu = [UILabel new];
    _pName.backgroundColor = [UIColor clearColor];
    _pPrice.backgroundColor = [UIColor clearColor];
    _pZhangDie.backgroundColor = [UIColor clearColor];
    _pFuDu.backgroundColor = [UIColor clearColor];
    _pName.textColor = _pPrice.textColor = _pZhangDie.textColor = _pFuDu.textColor = kMYHexToRGB(0xffffff, 1);
    _pName.textAlignment = _pPrice.textAlignment = _pZhangDie.textAlignment = _pFuDu.textAlignment = NSTextAlignmentCenter;
//    _pPrice.font = kHZDefaultFont;
    _pPrice.font = [UIFont boldSystemFontOfSize:22];
    _pName.font = [UIFont systemFontOfSize:16];
    _pZhangDie.font = _pFuDu.font = [UIFont systemFontOfSize:14];
    
    [self addSubview:_pName];
    [self addSubview:_pPrice];
    [self addSubview:_pZhangDie];
    [self addSubview:_pFuDu];
    
    [self p_initConstraints];
}

#pragma mark -
#pragma mark private
- (void)p_initConstraints
{
    [_pName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(kMargin);
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(self);
        make.bottom.mas_equalTo(_pPrice.mas_top).offset(-5);
    }];
    [_pPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(self);
        make.bottom.mas_equalTo(_pZhangDie.mas_top);
        make.height.mas_equalTo(_pName).multipliedBy(2.f);
    }];
    [_pZhangDie mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(_pFuDu.mas_left);
        make.bottom.mas_equalTo(self);
        make.height.mas_equalTo(_pName);
    }];
    [_pFuDu mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_pZhangDie);
        make.right.mas_equalTo(self);
        make.bottom.mas_equalTo(self).offset(-kMargin+2);
        make.width.mas_equalTo(_pZhangDie);
        make.height.mas_equalTo(_pZhangDie);
    }];
}

@end
